package com.itheima_07;

import java.io.*;
import java.net.Socket;

/*
    客户端，数据来源自键盘录入，直到输入的数据是886，程序结束
 */
public class ClientDemo {
    public static void main(String[] args) throws IOException {
        //创建客户端Socket对象
        Socket s = new Socket("192.168.189.1",10086);
        //数据来源键盘录入，直到输入的数据是886，停止发送
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //封装输出流对象
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
        String line;
        while ((line=br.readLine())!=null){
            if ("886".equals(line)){
                break;
            }
            bw.write(line);
            bw.newLine();
            bw.flush();
            System.out.println("数据:"+line+"写入文本成功");
        }
        //释放资源
        s.close();

    }
}
